﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFIDA.U9.PM.Rcv;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;

namespace UFIDA.U9.Cust.LS.PlugBE
{
    internal class AFKPRExtendtoZG : IEventSubscriber
    {
        public void Notify(params object[] args)
        {

            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) return;
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;

            if (key == null || key.GetEntity() == null) return;


            //请购
            UFIDA.U9.PR.PurchaseRequest.PR pr = key.GetEntity() as UFIDA.U9.PR.PurchaseRequest.PR;
            if (pr == null) return;

            #region 请购的时候,如果料品名称包含(整改),把头上的COPQ打钩

           // if (pr.Status == PR.PurchaseRequest.PRStatusEnum.OpenOpen)
            if (pr.Status == PR.PurchaseRequest.PRStatusEnum.OpenOpen)

                {
                    //请购的时候,如果料品名称包含(整改),把头上的COPQ打钩

                    foreach (var line in pr.PRLineList)
                    {
                        if ((line.ItemInfo.ItemName.Contains("整改")))
                        {
                        
                            pr.DescFlexField.PrivateDescSeg5 = "True";
                         
                    }
                    else
                    {
                        
                            pr.DescFlexField.PrivateDescSeg5 = "False";
                        

                    }
                    }

                
            }

            #endregion
        }
    }

}
